import { defineConfig } from "umi";
import routes from "../src/routes";
const PRODUCTION = process.env.NODE_ENV === "production";

export default defineConfig({
  // 注册所需插件
  plugins: [
    "@umijs/plugins/dist/qiankun",
    "@umijs/plugins/dist/initial-state",
    "@umijs/plugins/dist/model",
    "@umijs/plugins/dist/locale",
  ],
  // 子应用部署在二级目录，需要添加前缀
  publicPath: PRODUCTION ? "/childApps/app1/" : "/",
  routes,
  npmClient: "yarn",
  // 启用插件
  model: {},
  initialState: {},
  // 开启子应用乾坤配置
  qiankun: {
    // 此配置表示当前应用作为子应用的角色，开启配置会为当前应用自动添加应用名为baseUrl
    // 这里的应用名为package.json文件中的name
    slave: {},
    // 如果当前子应用嵌套另外一个子应用，则需开启master配置
    master: {
      apps: [
        {
          name: "app2",
          // entry: '/childApps/app2/' // 生产入口
          // entry: "http://localhost:8002", // 本地调试入口
          entry: PRODUCTION ? "/childApps/app2/" : "http://localhost:8002",
        },
      ],
    },
  },
});